<%@ include file="/common/taglibs.jsp"%>

<head>
    <title><fmt:message key="newsDetail.title"/></title>
    <meta name="heading" content="<fmt:message key='newsDetail.heading'/>"/>
    <sx:head/>
</head>

<c:set var="delObject" scope="request"><fmt:message key="newsList.news"/></c:set>
<script type="text/javascript">var msgDelConfirm =
   "<fmt:message key="delete.confirm"><fmt:param value="${delObject}"/></fmt:message>";
</script>

<div class="span2">
    <h2><fmt:message key="newsDetail.heading"/></h2>
    <fmt:message key="newsDetail.message"/>
</div>

<div class="span7">
    <s:form id="newsForm" action="saveNews" method="post" validate="true" cssClass="well form-horizontal">
    	<s:hidden key="news.id"/>
    	<fieldset class="control-group">
    	<label class="control-label"> PostDate: </label>
    	<div class="controls">
    	<sx:datetimepicker  required="true" name="news.postDate" value="news.postDate"/>
    	<sx:datetimepicker  required="true" name="hourformat" value="hourformat" type="time"/>
    	</div>
		</fieldset>
		<s:select required = "true" name="news.systemuser.id" list="systemuserList" listKey="id" listValue="name"   label="Systemusers"></s:select>	
		<c:if test="${not empty news.id}">
    	<fieldset class="control-group">
    	<label class="control-label">  </label>
    	<div class="controls">
    			<a href="editSystemuser?id=<c:out value="${news.systemuser.id}"/>">View <c:out value="${news.systemuser.name}"/></a>
    	</div>
		</fieldset>
		 </c:if>
        <s:textfield key="news.title" required="true" maxlength="100" />
        <s:textfield key="news.viewTimes" required="true" maxlength="255" />
        <s:textarea key="news.content" required="true" maxlength="255" id="Content"/>       
     	<c:if test="${(empty news.picturenews.id)&&(not empty news.id)}">
	     	<fieldset class="control-group">
	    	<label class="control-label"> PictureNews: </label>
	    	<div class="controls">
	    	<s:a href="editPictureNews"  label="Picture news">Add Picture News</s:a>
	    	</div>
			</fieldset>
        </c:if>
     	<c:if test="${not empty news.picturenews.id}">
	     	<fieldset class="control-group">
	    	<label class="control-label"> PictureNews:  </label>
	    	<div class="controls">
	    	<img src="/picturenews/<c:out value="${news.picturenews.pictureName}"/>" />
	    	</div>
			</fieldset>
	     	<fieldset class="control-group">
	    	<label class="control-label"> </label>
	    	<div class="controls">
			<a href="editPictureNews?id=<c:out value="${news.picturenews.id}"/>">View PictureNews</a>
	    	</div>
			</fieldset>
        </c:if>

        <div id="actions" class="form-actions">
            <s:submit type="button" cssClass="btn btn-primary" method="save" key="button.save" theme="simple">
                <i class="icon-ok icon-white"></i> <fmt:message key="button.save"/>
            </s:submit>
            <c:if test="${not empty news.id}">
                <s:submit type="button" cssClass="btn btn-warning" method="delete" key="button.delete"
                    onclick="return confirmMessage(msgDelConfirm)" theme="simple">
                    <i class="icon-trash icon-white"></i> <fmt:message key="button.delete"/>
                </s:submit>
            </c:if>
            <s:submit type="button" cssClass="btn" method="cancel" key="button.cancel" theme="simple">
                <i class="icon-remove"></i> <fmt:message key="button.cancel"/>
            </s:submit>
        </div>
    </s:form>
       <% 
		CKEditorConfig settings = new CKEditorConfig();
		settings.addConfigValue("width","500");
		settings.addConfigValue("height","500");
		%>
   <ckeditor:replace  basePath="/ckeditor/" replace ="Content" config="<%=settings %>"/> 

</div>

<script type="text/javascript">
    $(document).ready(function() {
        $("input[type='text']:visible:enabled:first", document.forms['newsForm']).focus();
    });
</script>
